from typing import Any

from recruit.domain.models.base import BaseModel


def check_attr_model(
        model: type[BaseModel],
        data: dict[str, Any],
        empty_keys: tuple[str, ...] | None = None
) -> None:
    _model = model(**data)
    if data is not None:
        for key, value in data.items():
            assert getattr(_model, key) == value
    if empty_keys is not None:
        for key in empty_keys:
            assert getattr(_model, key) is None


def check_json_schema(
        model: type[BaseModel],
        keys: tuple[str, ...]
) -> None:
    json_schema = model.model_json_schema()
    assert json_schema.get('properties')
    properties = json_schema['properties']
    assert sorted(tuple(properties)) == sorted(keys)
    for key in keys:
        assert properties[key].get('description')
